import { cardTypesMap } from '@/dicts/dayBooks';
import { request } from '../http';

const tableName = 'tradingTypes';

export const tradingTypesApi = {
  list(params: any) {
    return request.get(`/admin/${tableName}`, params);
  },
  detail(id: string | any) {
    return request.delete(`/admin/${tableName}/${id}`);
  },
  add(params: any) {
    return request.post(`/admin/${tableName}`, params);
  },
  update(params: any,) {
    return request.put(`/admin/${tableName}/${params.id}`, params);
  },
  delete(id: string | any) {
    return request.delete(`/admin/${tableName}/${id}`);
  },
  remove(ids: any[]) {
    return request.post(`/admin/${tableName}/remove`, ids);
  },
}

export function getColumnShowText(e: any) {
  let showText = e.name;
  if (e.card_type) {
    showText += `[${cardTypesMap[e.card_type]}:${e.card_number}]`
  }
  return showText;
}